﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;

namespace Entity
{
    public class NX_DETAI
    {
        private String MANXDT, MADT, MAGV, DANHGIA, GHICHU;
        private int SOTIETCHUAN;

        public int sotietchuan
        {
            get { return SOTIETCHUAN; }
            set { SOTIETCHUAN = value; }
        }

        public String maNXDT
        {
            get { return MANXDT; }
            set { MANXDT = value; }
        }
        public String maDT
        {
            get { return MADT; }
            set { MADT = value; }
        }
        public String maGV
        {
            get { return MAGV; }
            set { MAGV = value; }
        }
        public String danhgia
        {
            get { return DANHGIA; }
            set { DANHGIA = value; }
        }
        public String ghichu
        {
            get { return GHICHU; }
            set { GHICHU = value; }
        }


        /// <summary>
        /// 
        /// </summary>
        DataBaseAccess dataBaseAccess = new DataBaseAccess();

        public void hienthi_NXDeTai(DataGridView dtgNXdetai)
        {
            String excuteString = "SELECT  N.*,D.HOCKI,D.NAMHOC FROM NX_DETAI N, DETAI D " +
                                    "WHERE D.MADT = N.MADT";
            DataTable dataTable = new DataTable();
            dataTable = dataBaseAccess.getDataTable(excuteString);
            dtgNXdetai.DataSource = dataTable;
        }

        public void them_NXDeTai(NX_DETAI nxdetai)
        {
            String excuteString = "INSERT INTO NX_DETAI VALUES('" + nxdetai.maNXDT + "','"
                                                                  + nxdetai.maDT + "','"
                                                                  + nxdetai.maGV + "','"
                                                                  + nxdetai.danhgia + "','"
                                                                  + nxdetai.ghichu + "',"
                                                                  + nxdetai.sotietchuan + ")";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void sua_NXDeTai(NX_DETAI nxdetai)
        {
            String excuteString = "UPDATE NX_DETAI SET  MADT='" + nxdetai.maDT +
                                                    "', MAGV ='" + nxdetai.maGV +
                                                    "', DANHGIA='" + nxdetai.danhgia +
                                                    "', GHICHU='" + nxdetai.ghichu +
                                                    "'  WHERE MA_NXDT='" + nxdetai.maNXDT + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void  xoa_NXDeTai(String manxdetai)
        {
            String excuteString = "DELETE FROM NX_DETAI WHERE MA_NXDT='" + manxdetai + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }



    }
}
